package com.wn.t;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

import com.opensymphony.xwork2.util.LocalizedTextUtil;

public class T_I18n {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String key = "warning.lang";
		ResourceBundle rb = ResourceBundle.getBundle("com/wn/t/i18n");
		String[] langs = rb.getString(key).split(",");
		for (String lang : langs) {
			String text = rb.getString(key + "." + lang);
			Locale locale = getLocale(rb
					.getString(key + "." + lang + ".locale"));
			System.out.println(text + ":" + locale.getDisplayLanguage()
					+ locale.getDisplayCountry());
		}
		String localeKey = "lang.{0}.{1}.locale";
		MessageFormat mf = new MessageFormat("(\\d)");
		System.out.println(mf.format(localeKey, "a", "b"));
	}

	private static Locale getLocale(String key) {
		return LocalizedTextUtil.localeFromString(key, null);
	}
}
